//action设置的创建

import axios from 'axios';

import {INIT_LIST_ACTION,CHANGE_INPUT_VALUE,ADD_TODO_ITEM,DEL_TODO_ITEM,GET_INIT_LIST} from '../store/actionType'

export const initListAction = (value)=>({
    type:INIT_LIST_ACTION,
    value
})

export const getInputChangeAction = (value)=>({
    type:CHANGE_INPUT_VALUE,
    value
})

export const getAddItemAction = (value)=>({
    type:ADD_TODO_ITEM,
    value
})

export const getDelItemAction = (value)=>({
    type:DEL_TODO_ITEM,
    value
})

//redux-thunk
// export const getTodoList = ()=>{
//     return (dispatch)=>{
//         console.log(dispatch)
//         axios.get('http://localhost/list.json').then((res)=>{
//             const data = res.data ? res.data : [];
//             const action = initListAction(data);
//             //将action发送给store
//             dispatch(action);
//             // console.log(data);
//         }).catch(()=>{

//         })
//     }
// }

//redux-saga
export const getInitList = ()=>({
    type:GET_INIT_LIST
})

